from account.account_service import AccountService, accounts_write_lock
from common.logger import logger
import json
import spider_config
from database.park_token_table import ParkTokenTable

class JieAccountService(AccountService):
    def active(self):
        self.fetch()

    def fetch(self):
        with accounts_write_lock:
            self._clear()
            with ParkTokenTable() as db:
                data = db.query_all(spider_config.jie_park_id)
                for item in data:
                    self._accounts.append(json.loads(item.data))
            logger.success(f"补充捷停车账号完成，剩余账号数量: {len(self._accounts)}")
